﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace Hired
{
    public partial class viewprofile : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["username"] != null)
            {
                string username = Request.QueryString["username"];
                string accountType = DBAccount.RetrieveAccountTypeByUsername(username);
                switch (accountType)
                {
                    case "JobseekerAccount":
                        Page.EnableViewState = false;   // disabling ViewState to allow Server.Transfer to successfully work
                        Server.Transfer("viewjsprofile.aspx?username=" + Server.UrlEncode(username));
                        break;
                    case "CompanyAccount":
                        Page.EnableViewState = false;
                        Server.Transfer("viewempprofile.aspx?username=" + Server.UrlEncode(username));
                        break;
                    case "EmployerPassport":
                        Page.EnableViewState = false;
                        CompanyAccount ca = DBCompanyAccount.RetrieveCompanyAccountByEmployerID(username, false);
                        Server.Transfer("viewempprofile.aspx?username=" + Server.UrlEncode(ca.Username));
                        break;
                    case "AdminStaffAccount":
                        lblMessage.Text = "This account belongs to an administrator of Hired.";
                        break;
                }
            }
        }
    }
}